import groovy.swing.SwingBuilder
import java.awt.BorderLayout as BL



def swing = {
   
    new SwingBuilder().edt {
      frame(title:'Frame', size:[100,300], show: true,undecorated:true, locationRelativeTo : null) {
        flowLayout()
        textlabel = label(text:"Click the button!")
        button(text:'Domain',
             actionPerformed: {println "clicked1"; System.exit(0)})
        button(text:'Controller',
             actionPerformed: {println "clicked2"; System.exit(0)})
        button(text:'GSP Create',
             actionPerformed: {println "clicked3"; System.exit(0)})
        button(text:'Domain',
             actionPerformed: {println "clicked4"; System.exit(0)})
      }
    }
}

if (args.length > 0) {// 有参数
    def source = args[0] 
    if (-1 != source.indexOf("grails-app")) {//是grails项目
        def dirarray = source.tokenize('\\')
        def key ,domain
        dirarray.eachWithIndex{elem , i-> if (elem == "grails-app") key = i+1 }
        if (dirarray[key] == "view") {
            domain = dirarray[dirarray.size()-2]
        }else{
            domain = dirarray[dirarray.size()-1].substring(0,dirarray[dirarray.size()-1].length() - 7).replace(dirarray[key] , '')
        }
        println domain

    }
}